package org.niu.str;

public class BalancedStringSplit {
    public int balancedStringSplit(String s) {
        int cnt = 0;
        int ans = 0;
        for (int i = 0; i < s.length(); i++) {
            if(s.charAt(i) == 'L') cnt++;
            else if(s.charAt(i) == 'R') cnt--;
            if(cnt == 0) ans++;
        }
        return ans;
    }
}
